package com.mitrais.training.yoga;

import java.awt.Font;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;

import javax.swing.ButtonGroup;
import javax.swing.JButton;
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JRadioButton;
import javax.swing.SwingUtilities;
import javax.swing.UIManager;

import org.dyno.visual.swing.layouts.Constraints;
import org.dyno.visual.swing.layouts.GroupLayout;
import org.dyno.visual.swing.layouts.Leading;

//VS4E -- DO NOT REMOVE THIS LINE!
public class GuiExerciseDay2 extends JFrame {

	private static final long serialVersionUID = 1L;
	private JRadioButton jRadioButton0;
	private JRadioButton jRadioButton1;
	private JRadioButton jRadioButton2;
	private JButton jButton0;
	private JLabel jLabel0;
	private ButtonGroup buttonGroup1;
	private static final String PREFERRED_LOOK_AND_FEEL = "com.sun.java.swing.plaf.windows.WindowsLookAndFeel";
	public GuiExerciseDay2() {
		initComponents();
	}

	private void initComponents() {
		setLayout(new GroupLayout());
		add(getJLabel0(), new Constraints(new Leading(113, 12, 12), new Leading(18, 12, 12)));
		add(getJRadioButton0(), new Constraints(new Leading(121, 12, 12), new Leading(49, 10, 10)));
		add(getJRadioButton1(), new Constraints(new Leading(121, 12, 12), new Leading(73, 12, 12)));
		add(getJRadioButton2(), new Constraints(new Leading(121, 12, 12), new Leading(97, 12, 12)));
		add(getJButton0(), new Constraints(new Leading(121, 12, 12), new Leading(133, 12, 12)));
		initButtonGroup1();
		setSize(302, 182);
	}

	private void initButtonGroup1() {
		buttonGroup1 = new ButtonGroup();
		buttonGroup1.add(getJRadioButton0());
		buttonGroup1.add(getJRadioButton1());
		buttonGroup1.add(getJRadioButton2());
	}

	private JLabel getJLabel0() {
		if (jLabel0 == null) {
			jLabel0 = new JLabel();
			jLabel0.setFont(new Font("Dialog", Font.BOLD, 12));
			jLabel0.setText("Exercise Day 2");
		}
		return jLabel0;
	}

	private JButton getJButton0() {
		if (jButton0 == null) {
			jButton0 = new JButton();
			jButton0.setText("Execute");
			jButton0.addActionListener(new ActionListener() {

				public void actionPerformed(ActionEvent event) {
					jButton0ActionActionPerformed(event);
				}
			});
		}
		return jButton0;
	}

	private JRadioButton getJRadioButton2() {
		if (jRadioButton2 == null) {
			jRadioButton2 = new JRadioButton();
			jRadioButton2.setText("Task 3");
		}
		return jRadioButton2;
	}

	private JRadioButton getJRadioButton1() {
		if (jRadioButton1 == null) {
			jRadioButton1 = new JRadioButton();
			jRadioButton1.setText("Task 2");
		}
		return jRadioButton1;
	}

	private JRadioButton getJRadioButton0() {
		if (jRadioButton0 == null) {
			jRadioButton0 = new JRadioButton();
			jRadioButton0.setSelected(true);
			jRadioButton0.setText("Task 1");
		}
		return jRadioButton0;
	}

	private static void installLnF() {
		try {
			String lnfClassname = PREFERRED_LOOK_AND_FEEL;
			if (lnfClassname == null)
				lnfClassname = UIManager.getCrossPlatformLookAndFeelClassName();
			UIManager.setLookAndFeel(lnfClassname);
		} catch (Exception e) {
			System.err.println("Cannot install " + PREFERRED_LOOK_AND_FEEL
					+ " on this platform:" + e.getMessage());
		}
	}

	/**
	 * Main entry of the class. Note: This class is only created so that you can
	 * easily preview the result at runtime. It is not expected to be managed by
	 * the designer. You can modify it as you like.
	 */
	public static void main(String[] args) {
		installLnF();
		SwingUtilities.invokeLater(new Runnable() {
			public void run() {
				GuiExerciseDay2 frame = new GuiExerciseDay2();
				frame.setDefaultCloseOperation(GuiExerciseDay2.EXIT_ON_CLOSE);
				frame.setTitle("GuiExerciseDay2");
				frame.getContentPane().setPreferredSize(frame.getSize());
				frame.pack();
				frame.setLocationRelativeTo(null);
				frame.setVisible(true);
			}
		});
	}

	private void jButton0ActionActionPerformed(ActionEvent event) {
		if (jRadioButton0.isSelected()) {
			DayTwoTaskOne.execute();
		} else if (jRadioButton1.isSelected()) {
			DayTwoTaskTwo.execute();
		} else {
			DayTwoTaskThree.execute();
		}
	}

}
